<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>教师后台-不学也通</title>
    <link rel="shortcut icon" href="../康笑长结业课.jpg" type="image/x-icon">
    <style>
        .container {
            min-height: 100vh;
        }

        .container .nav {
            height: 100%;
            background-color: #fff;
        }

        .link-secondary {
            text-decoration: none;
        }

        .link-secondary:hover {
            color: #0d6efd !important;
        }
        .position-relative .position-absolute {
            display: none;
        }

        .card:hover .position-absolute {
            display: block;
        }
    </style>
</head>

<body>
    <!-- container是bootstrap的居中窄的显示方案 -->
    <div class="container bg-body">
        <div class="row">
            <div class="col-md-2 leftmenu" id="leftmenu">

            </div>
            <div class="col-md-9 kc ms-3">
                <div class="row">
                    <!-- row似乎不能使用flex布局 -->
                    <ul class="nav nav-tabs">
                        <li class="nav-item">
                            <a class="nav-link nav-tab active" aria-current="page" href="#">我教的课程</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link nav-tab" href="#">我学的课程</a>
                        </li>
                        <li class="nav-item">
                            <select class="form-select" aria-label="select example">
                                <option selected value="-1">请选择学期</option>
                                <option value="0">2022-2023学期</option>
                                <option value="1">2022-2023学期</option>
                                <option value="2">2021-2022学期</option>
                                <option value="3">2021-2022学期</option>
                            </select>
                        </li>
                        <li class="nav-item ms-5" style="position: relative;">
                            <input type="text" class="form-control rounded-pill" placeholder="请输入课程名">
                            <i class="bi bi-search" style="position: absolute; right: 1rem; top: 0.7rem;"></i>
                        </li>
                        <li class="nav-item ms-5">
                            <a class="nav-link link-success" href="#">
                                <i class="bi bi-plus-circle-fill"></i>
                                创建文件夹
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link link-success" href="./createcourse.html">
                                <i class="bi bi-plus-circle-fill"></i>
                                创建课程
                            </a>
                        </li>
                    </ul>
                    <div class="row" id="courses">
                        <!-- <div class="col-sm-6 col-md-4">
                            <div class="card m-3" style="width: 18rem;">
                                <img src="../good.png" width="262" height="262" class="card-img-top" alt="小黑屋">
                                <div class="card-body">
                                    <h5 class="card-title">阿康的导演日志</h5>
                                    <h6 class="mt-1 text-muted">阿康的教学工作室</h6>
                                    <h6 class="mt-1 text-muted">课程号:mb-001</h6>
                                    <h6 class="mt-1 text-muted">教师:阿康</h6>
                                    <h6 class="mt-1 text-muted d-flex justify-content-between">
                                        <div>康笑长教学小黑屋</div>
                                        <div>点击量99+<i class="bi bi-chevron-compact-right"></i></div>
                                    </h6>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-6 col-md-4">
                            <div class="card m-3" style="width: 18rem;">
                                <img src="../豪教兽.jpg" width="262" height="262" class="card-img-top" alt="...">
                                <div class="card-body">
                                    <h5 class="card-title">阿豪的主演经验</h5>
                                    <h6 class="mt-1 text-muted">阿康的教学工作室</h6>
                                    <h6 class="mt-1 text-muted">课程号:mb-002</h6>
                                    <h6 class="mt-1 text-muted">教师:阿豪</h6>
                                    <h6 class="mt-1 text-muted d-flex justify-content-between">
                                        <div>康笑长教学小黑屋</div>
                                        <div>点击量99+<i class="bi bi-chevron-compact-right"></i></div>
                                    </h6>
                                </div>
                            </div>
                        </div>

                        <div class="col-sm-6 col-md-4">
                            <div class="card m-3" style="width: 18rem;">
                                <img src="../琛教兽.jpg" width="262" height="262" class="card-img-top" alt="...">
                                <div class="card-body">
                                    <h5 class="card-title">阿琛的做零经验</h5>
                                    <h6 class="mt-1 text-muted">阿康的教学工作室</h6>
                                    <h6 class="mt-1 text-muted">课程号:mb-003</h6>
                                    <h6 class="mt-1 text-muted">教师:阿琛</h6>
                                    <h6 class="mt-1 text-muted d-flex justify-content-between">
                                        <div>康校长教学小黑屋</div>
                                        <div>点击量99+<i class="bi bi-chevron-compact-right"></i></div>
                                    </h6>
                                </div>
                            </div>
                        </div>

                        <div class="col-sm-6 col-md-4">
                            <div class="card m-3" style="width: 18rem;">
                                <img src="../康校长结业课.jpg" width="262" height="262" class="card-img-top" alt="...">
                                <div class="card-body">
                                    <h5 class="card-title">康笑长结业课</h5>
                                    <h6 class="mt-1 text-muted">阿康的教学工作室</h6>
                                    <h6 class="mt-1 text-muted">课程号:mb-004</h6>
                                    <h6 class="mt-1 text-muted">教师:康笑长</h6>
                                    <h6 class="mt-1 text-muted d-flex justify-content-between">
                                        <div>康校长教学小黑屋</div>
                                        <div>点击量99+<i class="bi bi-chevron-compact-right"></i></div>
                                    </h6>
                                </div>
                            </div>
                        </div> -->
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="d-grid gap-3 justify-content-md-end fixed-bottom mb-3">
        <button class="btn btn-outline-primary rounded-pill btn-lg " type="button">
            <i class="bi bi-megaphone-fill"></i>
            更新公告
        </button>
        <button class="btn btn-outline-primary rounded-pill btn-lg " type="button">
            <i class="bi bi-question-circle-fill"></i>
            使用帮助
        </button>
        <button class="btn btn-outline-primary rounded-pill btn-lg " type="button">
            <i class="bi bi-headset"></i>
            在线客服
        </button>
        <button class="btn btn-outline-primary rounded-pill btn-lg " type="button">
            <i class="bi bi-capslock-fill"></i>返回顶部
        </button>
    </div>
    <script type="module" src="../js/main.js"></script>
    <script src="../js/jquery.min.js"></script>
    <script src="../js/common.js"></script>
    <script>
        $(document).ready(function () {
            // 当用户点击class是nav-tab的标签给给该标签(添加之前删除所有active类)添加active类
            $(".nav-tab").click(function (e) {
                // 删除nav-tab所有的active类
                $(".nav-tab").removeClass("active");
                // 给点击的标签添加active
                $(this).addclass("active");
            })
            $.get("https://unicloud.codecore.cn/ms/courseAll?teacher_id=645484f2819ce8deeea2a59b", {}, function (params) {
                if (params.errCode == 0) {
                    for (let i = 0; i < params.data.length; i++) {
                        const elem = params.data[i]
                        $("#courses").append($(`<div class="col-sm-6 col-md-4">
                                <div class="card col-md-4 ms-3 mt-3 position-relative" style="width: 18rem;">
                        <div class="position-absolute top-0 end-0" style="right: 0;">
                            <button class="btn btn-warning"data-id="${elem._id}">编辑</button>
                            <button class="btn btn-info shan"data-id="${elem._id}">退课</button>
                        </div>
                                <img src="${elem.course_url}" width="262" height="262" class="card-img-top" alt="...">
                                <div class="card-body">
                                    <h5 class="card-title">${elem.course_name}</h5>
                                    <h6 class="mt-1 text-muted">阿康的教学工作室</h6>
                                    <h6 class="mt-1 text-muted">课程号:${elem.teacher_id}</h6>
                                    <h6 class="mt-1 text-muted">教师:${elem.teacher_name}</h6>
                                    <h6 class="mt-1 text-muted">院系:${elem.course_department}</h6>
                                    <h6 class="mt-1 text-muted d-flex justify-content-between">
                                        <div>康校长教学小黑屋</div>
                                        <div>点击量99+<i class="bi bi-chevron-compact-right"></i></div>
                                    </h6>
                                </div>
                            </div>
                        </div>`))
                    }
                }
            })
            $("#courses").delegate("button.btn-info", "click", function () {
                let data = $(this).data();
                $.post("http://unicloud.codecore.cn/ms/courseRemove", data, function (params) {
                    console.log(params);
                    if (params.errCode == 0) {
                        location.reload();
                    } else { alert("退课异常") }
                })
            });    
            $("#courses").delegate("button.btn-warning", "click",function(){
                let data = $(this).data();
                // 跳转到新页面 并将要编辑的数据的id编号带过去
                location.href = `./edit_index.html?id=${data.id}`
            });
        })

    </script>
</body>

</html>